package com.orange.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.orange.util.CourseAnylyseExport;
import com.orange.util.CourseRecordExport;
import com.orange.util.FeedBackExport;
import com.orange.util.InterviewAnalyseExport;
import com.orange.util.ReturnCode;



@Controller
@RequestMapping("/exportExcel")
public class TableExportExcel extends BaseController{
	private static final Logger logger = Logger.getLogger(TableExportExcel.class);
/*	@Autowired
	private CourseRecordServie courseRecordServie;
	@Autowired
	private CourseAnalyseService courseAnalyseService;
	@Autowired
	private InterviewAnalyseService interviewAnalyseService;
	@Autowired
	private FeedBackService feedBackService;*/
	
	@RequestMapping(value = "/courseRecord")
	@ResponseBody
	public ResponseEntity<String> courseRecord(HttpServletRequest request,HttpServletResponse response){
		//String expertId = map.get("expertId");//(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		
		/*String sign = map.get("sign");
		String schoolId = map.get("schoolId");
		if(null == expertId){
			return toResponse(null, ReturnCode.FAIL, "未登录!");
		}
		if(schoolId == null || StringUtils.isBlank(schoolId)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "schoolId不能为空");
		}
		if(sign == null || StringUtils.isBlank(sign)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "sign不能为空");
		}*/
		try {
			//CourseRecord cr = this.courseRecordServie.queryCourseRecordById(sign,schoolId,expertId);
			
			String filename = "(一) 随堂听课记录表";
			List<List<String>> listdata = new ArrayList<List<String>>();
			List<String> list = new ArrayList<String>();
			list.add("(一) 随堂听课记录表");
			listdata.add(list);
			
			List<String> list1 = new ArrayList<String>();
			list1.add("评估学校");
			list1.add(" ");
			list1.add("参评类别");
			list1.add(" ");
			list1.add("申报时间");
			list1.add(" ");
			listdata.add(list1);
			
			List<String> list2 = new ArrayList<String>();
			list2.add("教师");
			list2.add(" ");
			list2.add("学科/专业");
			list2.add(" ");
			list2.add("班级");
			list2.add(" ");
			listdata.add(list2);
			
			List<String> list3 = new ArrayList<String>();
			list3.add("任教时间");
			list3.add(" ");
			list3.add("周课时数");
			list3.add(" ");
			list3.add("技术职称");
			list3.add(" ");
			listdata.add(list3);
			
			List<String> list4 = new ArrayList<String>();
			list4.add("教学内容");
			list4.add(" ");
			listdata.add(list4);
			
			List<String> list5 = new ArrayList<String>();
			list5.add("评价等第");
			list5.add("（优秀、良好、一般、较差）");
			list5.add(" ");
			listdata.add(list5);
			
			List<String> list6 = new ArrayList<String>();
			list6.add("总\r\n体\r\n评\r\n价\r\n与\r\n建\r\n议");
			list6.add(" ");
			listdata.add(list6);
			CourseRecordExport c = new CourseRecordExport();
			c.exportXLS(response, listdata, filename);
			return toResponse(null, ReturnCode.SUCCESS, "表格导出成功");
		} catch (Exception e) {
			logger.error(e);
			return toResponse(null, ReturnCode.FAIL, "表格导出失败");
		}		
	}
	
	@RequestMapping(value = "/courseAnalyse")
	@ResponseBody
	public ResponseEntity<String> courseAnalyse(HttpServletRequest request,HttpServletResponse response){
		/*String expertId = map.get("expertId");//(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		
		String sign = map.get("sign");
		String schoolId = map.get("schoolId");
		if(null == expertId){
			return toResponse(null, ReturnCode.FAIL, "未登录!");
		}
		if(schoolId == null || StringUtils.isBlank(schoolId)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "schoolId不能为空");
		}
		if(sign == null || StringUtils.isBlank(sign)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "sign不能为空");
		}*/
		try {
			//CourseAnalyse ca = this.courseAnalyseService.queryCourseAnalyseById(sign, schoolId, expertId);
			
			String filename = "(二) 专业/课程剖析记录表";
			List<List<String>> listdata = new ArrayList<List<String>>();
			List<String> list = new ArrayList<String>();
			list.add("(二) 专业/课程剖析记录表");
			listdata.add(list);
			
			List<String> list1 = new ArrayList<String>();
			list1.add("评估学校");
			list1.add(" ");
			list1.add("参评类别");
			list1.add(" ");
			list1.add("申报时间");
			list1.add(" ");
			listdata.add(list1);
			
			List<String> list2 = new ArrayList<String>();
			list2.add("说课人");
			list2.add(" ");
			list2.add("专业/课程名称");
			list2.add(" ");
			list2.add("技术职称");
			list2.add(" ");
			listdata.add(list2);
			
			List<String> list3 = new ArrayList<String>();
			list3.add("职务");
			list3.add(" ");
			listdata.add(list3);
			
			List<String> list4 = new ArrayList<String>();
			list4.add("说课内容");
			list4.add(" ");
			listdata.add(list4);
			
			List<String> list5 = new ArrayList<String>();
			list5.add("总\r\n体\r\n评\r\n价\r\n与\r\n建\r\n议");
			list5.add("总体评价:");
			list5.add("");
			listdata.add(list5);
			
			List<String> liNull = new ArrayList<String>();
			liNull.add(" ");
			listdata.add(liNull);
			listdata.add(liNull);
			
			List<String> list6 = new ArrayList<String>();
			list6.add(" ");
			list6.add("建议:");
			list6.add(" ");
			listdata.add(list6);
			listdata.add(liNull);
			listdata.add(liNull);
			
			List<String> list7 = new ArrayList<String>();
			list7.add(" ");
			list7.add("专家签名:");
			list7.add(" ");
			listdata.add(list7);
			
			CourseAnylyseExport c = new CourseAnylyseExport();
			c.exportXLS(response, listdata, filename);
			return toResponse(null, ReturnCode.SUCCESS, "表格导出成功");
		} catch (Exception e) {
			logger.error(e);
			return toResponse(null, ReturnCode.FAIL, "表格导出失败");
		}
	}
	
	@RequestMapping(value = "/interviewAnalyse")
	@ResponseBody
	public ResponseEntity<String> interviewAnalyse(HttpServletRequest request,HttpServletResponse response){
	/*	String expertId = map.get("expertId");//(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		
		String sign = map.get("sign");
		String schoolId = map.get("schoolId");
		if(null == expertId){
			return toResponse(null, ReturnCode.FAIL, "未登录!");
		}
		if(schoolId == null || StringUtils.isBlank(schoolId)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "schoolId不能为空");
		}
		if(sign == null || StringUtils.isBlank(sign)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "sign不能为空");
		}*/
		try {
			//InterviewAnalyse ia = this.interviewAnalyseService.queryInterviewAnalyseById(sign, expertId, schoolId);
			
			String filename = "(三) 访谈座谈记录表";
			List<List<String>> listdata = new ArrayList<List<String>>();
			List<String> list = new ArrayList<String>();
			list.add("(三) 访谈座谈记录表");
			listdata.add(list);
			
			List<String> list1 = new ArrayList<String>();
			list1.add("评估学校");
			list1.add(" ");
			list1.add("参评类别");
			list1.add(" ");
			list1.add("申报时间");
			list1.add(" ");
			listdata.add(list1);
			
			List<String> list2 = new ArrayList<String>();
			list2.add("身份");
			list2.add(" ");
			list2.add(" ");
			list2.add(" ");
			list2.add("部门/年级");
			list2.add(" ");
			listdata.add(list2);
			
			List<String> list3 = new ArrayList<String>();
			list3.add("访谈重点");
			list3.add(" ");
			listdata.add(list3);
			
			List<String> list4 = new ArrayList<String>();
			list4.add("身份");
			list4.add(" ");
			list4.add(" ");
			list4.add(" ");
			list4.add("部门/年级");
			list4.add(" ");
			listdata.add(list4);
			
			List<String> list5 = new ArrayList<String>();
			list5.add("访谈重点");
			list5.add(" ");
			listdata.add(list5);
			
			List<String> list6 = new ArrayList<String>();
			list6.add("身份");
			list6.add(" ");
			list6.add(" ");
			list6.add(" ");
			list6.add("部门/年级");
			list6.add(" ");
			listdata.add(list6);
			
			List<String> list7 = new ArrayList<String>();
			list7.add("访谈重点");
			list7.add(" ");
			listdata.add(list7);
			
			List<String> list8 = new ArrayList<String>();
			list8.add("反映情况或建议");
			listdata.add(list8);
			
			List<String> list9 = new ArrayList<String>();
			list9.add(" ");
			listdata.add(list9);
			listdata.add(list9);
			listdata.add(list9);
			listdata.add(list9);
			listdata.add(list9);
			listdata.add(list9);
			
			List<String> list10 = new ArrayList<String>();
			list10.add("注：如访谈对象为教师，属学校中层干部及以上人员,其部门\r\n栏请填写其所处部门、科室，普通教师则填写其所在学科组。");
			listdata.add(list10);
			
			listdata.add(list9);
			
			List<String> list11 = new ArrayList<String>();
			list11.add("专家签名:");
			list11.add(" ");
			listdata.add(list11);
			
			InterviewAnalyseExport e = new InterviewAnalyseExport();
			e.exportXLS(response, listdata, filename);
			return toResponse(null, ReturnCode.SUCCESS, "表格导出成功");
		} catch (Exception e) {
			logger.error(e);
			return toResponse(null, ReturnCode.FAIL, "表格导出失败");
		}
	}
	
	@RequestMapping(value = "/feedback")
	@ResponseBody
	public ResponseEntity<String> feedback(HttpServletRequest request,HttpServletResponse response){
		/*String expertId = map.get("expertId");//(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		
		String sign = map.get("sign");
		String schoolId = map.get("schoolId");
		if(null == expertId){
			return toResponse(null, ReturnCode.FAIL, "未登录!");
		}
		if(schoolId == null || StringUtils.isBlank(schoolId)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "schoolId不能为空");
		}
		if(sign == null || StringUtils.isBlank(sign)){
			return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "sign不能为空");
		}*/
		try {
			//FeedBack ia = this.feedBackService.queryFeedBackByExpert(expertId, schoolId);
			
			String filename = "(七) 现场考察评估反馈意见表";
			List<List<String>> listdata = new ArrayList<List<String>>();
			List<String> list = new ArrayList<String>();
			list.add("(七) 现场考察评估反馈意见表");
			listdata.add(list);
			
			List<String> list1 = new ArrayList<String>();
			list1.add("现场考察反馈意见");
			listdata.add(list1);
			
			List<String> list2 = new ArrayList<String>();
			list2.add("学校名称");
			listdata.add(list2);
			
			List<String> list3 = new ArrayList<String>();
			list3.add("评估类别");
			listdata.add(list3);
			
			List<String> list4 = new ArrayList<String>();
			list4.add("考察时间");
			listdata.add(list4);
			
			List<String> list5 = new ArrayList<String>();
			list5.add("一、专家组工作概况");
			listdata.add(list5);
			
			List<String> listNull = new ArrayList<String>();
			listNull.add(" ");
			listdata.add(listNull);
			listdata.add(listNull);
			listdata.add(listNull);
			
			List<String> list9 = new ArrayList<String>();
			list9.add("二、学校整体印象");
			listdata.add(list9);
			listdata.add(listNull);
			listdata.add(listNull);
			listdata.add(listNull);
			
			List<String> list13 = new ArrayList<String>();
			list13.add("三、学校建设成效、特色");
			listdata.add(list13);
			listdata.add(listNull);
			listdata.add(listNull);
			listdata.add(listNull);
			
			List<String> list17 = new ArrayList<String>();
			list17.add("四、存在问题和改进建议");
			listdata.add(list17);
			listdata.add(listNull);
			listdata.add(listNull);
			listdata.add(listNull);
			
			List<String> list21 = new ArrayList<String>();
			list21.add("专家组成员：");
			listdata.add(list21);
			listdata.add(listNull);
			
			FeedBackExport f = new FeedBackExport();
			f.exportXLS(response, listdata, filename);
			return toResponse(null, ReturnCode.SUCCESS, "表格导出成功");
		} catch (Exception e) {
			logger.error(e);
			return toResponse(null, ReturnCode.FAIL, "表格导出失败");
		}
		
	}
}
